package com.yyh.myblog.dao;

import com.yyh.myblog.entity.Comment;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author yyh
 * @date 2021/3/3 15:24
 */
public interface CommentRepository extends JpaRepository<Comment, Long> {

    /**
     * 根据blog的id查询所有父类评论
     * @param blogId
     * @param sort
     * @return
     */
    List<Comment> findByBlogIdAndParentCommentNull(Long blogId, Sort sort);

    @Transactional
    void deleteByBlogId(Long blogId);
}
